package test1224;

public class Test12 {
    public static void m12(int[] arr) {
        int a = 0;
        int b = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 1) {
                a = i;
            }
            if (arr[i] == 5) {
                b = i;
            }
        }
        int c = arr[a];
        arr[a] = arr[b];
        arr[b] = c;
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    public static void main(String[] args) {
        // 根据方法的调用需求实现方法
        // 互换元素1和元素5的位置
        int[] arr = {1, 2, 3, 4, 5};
        m12(arr);
    }
}
